﻿using System.Web.Mvc;
using System.Web.Profile;
using ClientApp.Models;
using CommonApp;

namespace ClientApp.Controllers
{

    public class HomeController : Controller
    {
       // [HttpGet]
        public ActionResult Index()
        {
            if (!User.Identity.IsAuthenticated)
                return RedirectToAction("LogOn", "Admission");

            var ensureSecurityRequired = Session[InfoKey.EnsureSecurity];
            if (ensureSecurityRequired != null && (bool) ensureSecurityRequired)
            {
                ViewBag.EnsureSecurity = true;
            }
           
            //var model = new QuickPayments();
            //model.Add(           
            //    new QuickPaymentModel(){
            //        Name = "First",
            //        PaymentId=1,
            //        CardNumber="4548553635470026",
            //        PaymentDetail="[{\"fieldLabel\": \"Contract number\", \"value\": \"1234567\", \"regex\": \"^\\w{7}$\", \"regexText\": \"Contract number should be 7 characters long\", \"hidden\": false, \"name\": \"\" },{\"fieldLabel\": \"\", \"value\": \"4548553635470026\", \"regex\": \"(?:)\", \"regexText\": \"\", \"hidden\": true, \"name\": \"cardNumber\" },{\"fieldLabel\": \"Currency\", \"value\": \"BYR\", \"regex\": \"\", \"regexText\": \"\", \"hidden\": false, \"name\": \"currency\" },{\"fieldLabel\": \"Amount\", \"value\": \"12\", \"regex\": \"\", \"regexText\": \"\", \"hidden\": false, \"name\": \"amount\" }]"
            //    });
            //model.Add(
            //    new QuickPaymentModel(){
            //        Name = "Second",
            //         PaymentId=1,
            //           CardNumber="4548553635470026",
            //        PaymentDetail="[{\"fieldLabel\": \"Contract number\", \"value\": \"1234567\", \"regex\": \"^\\w{7}$\", \"regexText\": \"Contract number should be 7 characters long\", \"hidden\": false, \"name\": \"\" },{\"fieldLabel\": \"\", \"value\": \"4548553635470026\", \"regex\": \"(?:)\", \"regexText\": \"\", \"hidden\": true, \"name\": \"cardNumber\" },{\"fieldLabel\": \"Currency\", \"value\": \"BYR\", \"regex\": \"\", \"regexText\": \"\", \"hidden\": false, \"name\": \"currency\" },{\"fieldLabel\": \"Amount\", \"value\": \"12\", \"regex\": \"\", \"regexText\": \"\", \"hidden\": false, \"name\": \"amount\" }]"
            //    });
            var profile = ProfileBase.Create(User.Identity.Name);
         
            var model = (QuickPayments)profile["Drafts"];
            return View(model);
        }
    }
}
